import java.util.*;

/**
 * @author: yangwk
 * @date: 2023/10/20
 * @description:
 **/
public class 查重 {
    public static void main(String[] args) {
        System.out.println(count(new String[]{"iwdvpbn", "hk", "iuop", "iikd", "kadgpf"}));
    }

    public static int count(String[] arr) {
        Set<Character> set = new HashSet<>();
        for (String s : arr) {
            for (char c : s.toCharArray()) {
                set.add(c);
            }
        }
        boolean[] dup = new boolean[arr.length];
        for (Character character : set) {
            boolean has = false;
            for (int i = 0; i < arr.length; i++) {
                if (!dup[i]) {
                    if (arr[i].contains(character.toString())) {
                        if (!has) {
                            has = true;
                        } else if (has) {
                            dup[i] = true;
                        }

                    }
                }

            }
        }
        int max = 0, min = 0;
        for (int i = dup.length - 1; i >= 0; i--) {
            for (int j = 0; j < i; j++) {
                if (!dup[j] && arr[j + 1].length() < arr[j].length()) {
                    String temp = arr[j + 1];
                    arr[j + 1] = arr[j];
                    arr[j] = temp;

                    boolean temp1 = dup[j + 1];
                    dup[j + 1] = dup[j];
                    dup[j] = temp1;
                }
            }
        }
        int count = 2;
        for (int i = dup.length - 1; i >= 0; i--) {
            if (!dup[i]) {
                if (count == 2) {
                    count--;
                    max = arr[i].length();
                } else if (count == 1) {
                    count--;
                    min = arr[i].length();
                } else {
                    break;
                }
            }
        }
        return max * min;
    }
}
